cmake_minimum_required(VERSION 3.18.0 FATAL_ERROR)

set(ROUTINE topk)

set(CMAKE_BUILD_TYPE "Release")

project(topk LANGUAGES C CXX CUDA)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to 'Release' as none was specified.")
    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "" "Debug" "Release")
else()
    message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)

if(${MODE} STREQUAL "PERF")
  add_definitions(-DPERF)  
elseif(${MODE} STREQUAL "PROFILE")
  add_definitions(-DPROFILE)  
elseif(${MODE} STREQUAL "EVAL")
  add_definitions(-DEVAL)  
endif()

include_directories("${CMAKE_SOURCE_DIR}/../release")

add_executable(topk topk.cu)
set_property(TARGET topk PROPERTY CUDA_ARCHITECTURES "${ARCH}")
target_include_directories(topk
    PUBLIC
        ${CUDA_INCLUDE_DIRS}
)